import request from '@/utils/request'
import Cookies from 'js-cookie'

// 获取key
export function getPublicKey() {
  return request({
    url: '/publicKey',
    method: 'get',
  })
}

// 获取用户手机号
export function getPhone() {
  return request({
    url: '/getPhone',
    method: 'get'
  })
}


// 发送验证码-未登录
export function sendSmsByPhone(phoneNumber) {
  return request({
    url: `/sendSmsByPhone/${phoneNumber}`,
    method: 'get'
  })
}

// 发送验证码
export function sendSms(phoneNumber) {
  return request({
    url: `/sendSms/${phoneNumber}`,
    method: 'get'
  })
}

export function checkSms(phoneNumber, code) {
  return request({
    url: `/checkSms/${phoneNumber}/${code}`,
    method: 'get'
  })
}

export function getCaptchaType() {
  return Cookies.get("captchaType")
}

export function setCaptchaType(captchaType) {
  return Cookies.set("captchaType", captchaType)
}

export function removeCaptchaType() {
  return Cookies.remove("captchaType")
}

export function getValidPhoneEnabled() {
  return Cookies.get("validPhoneEnabled")
}

export function setValidPhoneEnabled(boolFlag) {
  return Cookies.set("validPhoneEnabled", boolFlag)
}

export function removeValidPhoneEnabled() {
  return Cookies.remove("validPhoneEnabled")
}

export function getValidPhoneCode() {
  return Cookies.get("validPhoneCode")
}

export function setValidPhoneCode(boolFlag) {
  return Cookies.set("validPhoneCode", boolFlag)
}

export function removeValidPhoneCode() {
  return Cookies.remove("validPhoneCode")
}

